home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / MacQForth 1.0 / documentation / Lessons / LESSON 4 < prev    next >
Encoding:
Text File  |  1995-03-24  |  10.1 KB  |  62 lines  |  [TEXT/ALFA]

  1. er of bytes remaining in the QForth 
  2.                   dictionary.
  3.                   
  4.    set-start ( addr -- )  addr is the address of the word to be executed 
  5.                           when a memory image is loaded.  Use set-start 
  6.                           and then save the image.  When loaded the 
  7.                           selected word will execute immediately.
  8.                           
  9.    de ( addr -- )  addr is the address of a dictionary word.  DE is a 
  10.                    low-level decompiler and will show a disassembled 
  11.                    listing of the 65C02 code for the selected word.
  12.                    
  13.    type ( addr len -- )  type len characters starting at address addr.  
  14.                          Most Forths have this word.
  15.                          
  16.    R@ ( -- n )  copies a value from the return stack.  Use in place of r@ 
  17.                 since the latter doesn't work.
  18.    
  19.    Examples,
  20.    
  21.       : echo2
  22.            ." Enter your name: "  here 80 expect
  23.         cr ." You entered    : "  here span type cr ;
  24.       
  25.       
  26.       : .all
  27.           depth 0 do  . space  loop  cr ;
  28.    
  29.    
  30.    
  31. Exercises
  32. ---------
  33.  
  34.    Write the code to do the following.
  35.    
  36.    
  37. 4.1   Review the DISK.4TH file above.  Create a buffer large enough to 
  38.       hold 10 lines of up to 80 characters.  Create a word that will let 
  39.       the user enter 10 lines having the text go into the buffer.  Then, 
  40.       prompt the user for a file name, create the file, open the file and 
  41.       save the text to disk.  Use the DISK.4TH code (or a text editor) to 
  42.       read the file to verify that it was written correctly.
  43.       
  44. 4.2   Create a program that will draw on the screen at the current mouse 
  45.       position when the button is down.  The program ends when the user 
  46.       clicks on a '*' character in the lower left corner of the screen.  
  47.       Compare your program to the code in the file SCRIBBLE.4TH.
  48.  
  49. 4.3   Save your program above as a memory image and have it run when 
  50.       loaded.
  51.  
  52.  
  53.  
  54. \
  55. \ LESSON 4 -- MacQForth particulars
  56. \
  57. \ MacQForth lessons
  58. \
  59. \ by Ronald T. Kneusel, see address in READ ME FIRST file.
  60. \
  61. \ March 1995
  62.